Among known mobile terminals, one mobile terminal generally uses multiple different data collecting units, such as sensors, to acquire various external environmental data, thereby ensuring that an application running on the mobile terminal is capable of using the environmental data to implement certain functions. A smartphone, for example, generally includes a gravitational acceleration sensor used to collect gravitational acceleration data so as to implement such functions as switching a mobile phone screen between landscape and portrait orientations and flipping a mobile phone body to silence it when a call comes. The smartphone may further include an electronic compass sensor used to collect direction data so as to implement functions of a compass and the like and may further include an infrared sensor used to sense information about face distance so as to implement such functions as automatically closing a screen and a touchscreen during a call.
For an application implementing a certain function, data collected by multiple sensors may need to be used simultaneously to collaboratively implement a corresponding function. For example, an application that implements a function of closing screen display and a touchscreen when a user is making a call to avoid occurrence of an accidental touch when a face touches the touchscreen, requires not only data of the information about the face distance collected by the infrared sensor but also the gravitational acceleration data collected by the gravitational acceleration sensor. That is, the function of closing the screen display and the touchscreen is triggered only when the data of the information about the face distance collected by the infrared sensor represents that the face of a user approaches the screen, and at the same time, the gravitational acceleration data collected by the gravitational acceleration sensor represents that the mobile phone is in a portrait orientation.
In order to meet the requirements of such type of applications for data collected by multiple sensors, there is a data collecting method in the prior art. The method mainly includes collecting, by each sensor, data according to a respective collecting frequency and then determining, by each sensor, whether a difference between data collected this time and data collected for the previous time is greater than a predetermined threshold. If the difference is greater than the predetermined threshold, the data collected this time is reported to an intermediate layer. The intermediate layer selects from the data reported by each sensor one or more groups of data at a same moment or close moments and provides the one or more groups of data for the applications to use.
However, when an application requires, at a certain moment, data collected by multiple sensors, real-time and accurate data collected by each sensor at the certain moment may not be timely obtained if the foregoing data collecting method is used. Rather, data of each sensor at a moment close to the certain moment is obtained. Such data cannot meet requirements of some applications that have a relatively high requirement on data precision. For example, an application used to determine a posture and a motion track of a mobile phone needs to acquire data of the gravitational acceleration sensor, the electronic compass sensor, and a gyroscope sensor at the same time so as to calculate information about the posture, a position, a moving speed, and the like of the mobile phone. If a data collecting time point of the three sensors is not precisely at the same moment, an error may be caused in a calculation of this application.